import http from '@/utils/request'
const getId = () => {
	return new Date().getTime() + Math.round(Math.random() * 100000);
}
const menus = [
	{
		path: "home",
		localComponent: "/src/views/home.vue",
		icon: "icon-dashboard",
		title: "首页",
		cache: false,
		isMenu: true,
		id: getId(),
	},
	{
		icon: "icon-xitong",
		title: "模块",
		isMenu: true,
		id: getId(),
		children: [
			{
				path: "demo/table-demo",
				localComponent: "/src/modules/demo/views/table-demo.vue",
				icon: "icon-xitong",
				title: "分页表格示例",
				cache: true,
				isMenu: true,
				id: getId(),
			}
		]
	},
];

class MenuServiceTemp {


	useMenuNavApi() {
		return Promise.resolve({
			data: menus
		});
		// return http.get('/sys/menu/nav')
	}

	useAuthorityListApi() {
		return Promise.resolve({
			data: []
		});
		// return http.get('/sys/menu/authority')
	}

	useMenuListApi(type: Number) {
		// 菜单类型 0：菜单  1：按钮  2：接口
		const menuType = type === 2 ? 2 : 0

		return http.get('/sys/menu/list?type=' + menuType)
	}

	useMenuApi(id: Number) {
		return http.get('/sys/menu/' + id)
	}

	useMenuSubmitApi(dataForm: any) {
		if (dataForm.id) {
			return http.put('/sys/menu', dataForm)
		} else {
			return http.post('/sys/menu', dataForm)
		}
	}
}

const MenuService = new MenuServiceTemp();
export {
	MenuService
}
